<?php
require_once '../inc/config.php';
require_once '../inc/connexion.php';
   
$id = isset($_POST['chercher']);
        if (isset($_POST['envoyer'])&& isset($_POST['chercher'])){
             $id = isset($_POST['chercher']); 
          require_once '../inc/recherche.php';
             if(isset($_POST['nom']))      $nom=$_POST['nom'];
                else      $nom="";
             if(isset($_POST['prenom']))      $prenom=$_POST['prenom'];
                else      $prenom="";
                if(isset($_POST['photo']))      $photo=$_POST['photo'];
                else      $photo="";
             if(isset($_POST['liste_entreprise']))      $id_entreprise=$_POST['liste_entreprise'];
                else      $id_entreprise="";
             if(isset($_POST['telephone']))      $telephone=$_POST['telephone'];
                else      $telephone="";
             if(isset($_POST['email']))      $email=$_POST['email'];
                else      $email="";
             if(isset($_POST['observation']))      $observation=$_POST['observation'];
                else      $observation="";
   }     
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="utf-8">
        <title>Liste des contacts</title>
        <link href="../bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
        <link href="../css/style.css" type="text/css" rel="stylesheet">
        
    </head>
    <body>
        
        <?php 
        require_once "../inc/css_js_bootstrap/css_js_bootstrap.php"; 
        require_once '../inc/menus/menu_principal.php';
        
       
        ?> 
        <br><div id="div2">
                <h3>RECHERCHER DES CONTACTS</h3>
        </div><br>
        <br>
            <br><div id="div1">
            Veuillez saisir un nom :
                <input type="text" name="chercher" id="chercher" placeholder="Rechercher...">
                <input type="submit" name="envoyer" value="Chercher">
            
<?php        
$sql = "SELECT * FROM entreprises, contacts WHERE entreprises.id = contacts.id_entreprise AND nom='$id'"; 
$envoi_requete = mysqli_query($connexion_serveur, $sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());;

while($resultats = mysqli_fetch_array($envoi_requete)) { 
              ?>
            
        <table>
            <tr>
                <td class="col1"> n°</td>
                <td class="col2"><?php echo $resultats['id']; ?></td>
            </tr>
            <tr>
                 <td class="col1">Nom et prénom</td>
                 <td class="col2"><?php echo $resultats['nom']?>  <?php echo $resultats['prenom'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Entreprise</td>
                 <td class="col2"><?php echo $resultats['raison_sociale']; ?></td>
            </tr>
            <tr>
                 <td class="col1">Téléphone</td>
                 <td class="col2"><?php echo $resultats['telephone'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Photo</td>
                 <td class="col2"><?php echo $resultats['photo'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Email</td>
                 <td class="col2"><?php echo $resultats['email'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Photo</td>
                 <td class="col2" id="imag"><img src="<?php echo $resultats['photo'];  ?>"></td>
            </tr>
            <tr>
                 <td class="col1">Observations</td>
                 <td class="col2"><?php echo $resultats['observations'];  ?></td>
            </tr>
            <tr>
                <td class="col1"></td>
                <td class="col2"> <a href="../contacts/modifier_contacts.php?id=<?php echo $resultats['id'];?>" >Modifier</a></td>
            </tr>
            </table>
                <?php
                    }
                ?>
                
                <br>
           </div>
            
       
        <br>
    </body>
</html>
